import request from '@/request';

type listParams = {
  page: number; //否	int	页码
  page_size: number; //是	int	分页返回记录数
  classifyid?: number; //	否	ID
  region?: number; //	否	1中国 2日本 3韩国
  isfinish?: number; //	否	int	完结状态 1完结 0连载
  keyword?: string; //	否	string	关键词或口令码
  view_page_position?: string; //	否	string	关键词或口令码
};

export async function getHomeData() {
  return request.get<any>('busiapi/home/index', {});
}

export async function getAnimeList(data: listParams) {
  return request.get<API.BookList>('busiapi/anime/paginate', data);
}

export async function getMoreList(data: listParams) {
  return request.get<API.BookList>('busiapi/home/moreAnimes', data);
}

export async function getChangeAnimesList() {
  return request.get<API.BookItem[]>('busiapi/home/changeAnimes', {});
}

export async function getClassify() {
  return request.get<{ id: number; title: string }[]>('busiapi/classify', {});
}

export async function getBookrack(page: number, page_size: number) {
  return request.get<API.BookList>('busiapi/bookrack/mePaginate', { page, page_size });
}

export async function getBookDetail(anid: number) {
  return request.get<API.BookDetail>(`busiapi/anime/${anid}`, {});
}

export async function getHistoryList(data?: { page?: number; page_size?: number }) {
  return request.get<API.BookList>('busiapi/readHistory', data);
}

export async function getHistoryChaps(anid: number) {
  return request.get<{ history_chapter: number }>(`busiapi/readHistory/query/${anid}`, {});
}
